{% extends "bugs/base.html" %}
{% block content_title %}{% endblock %}
{% block breadcrumbs %}{% endblock %}
{% block main %}
<h2>Task #{{ taskitem.serial }} - {{ taskitem.summary }}</h2>
  <form enctype="multipart/form-data" method="post" action="">

  <div id="main"> 
    <p>{{ form.summary.label_tag }}{% if form.summary.field.required %}<font color="red">*</font>{% endif %}</p>	
    {% if form.summary.errors %}<p class="formerrors">{{ form.summary.errors }}</p>{% endif %}	 
    <p>{{ form.summary }}</p>
	
	<p>{{ form.description.label_tag }}{% if form.description.field.required %}<font color="red">*</font>{% endif %}</p>
	{% if form.description.errors %}<p class="formerrors">{{ form.description.errors }}</p>{% endif %}
	<p>{{ form.description }}</p>
	
	
	
	{{ form.status }}  
    {{ form.project }}	
    {{ form.kind }}
	{{ form.reporter }}

    <h4>History</h4>
    {{ test_html }}
	<ul>
	{% for his in taskhistory %}
    <li class="history">
      <h5><a href="mailto:{{ his.user.email }}">{{ his.user }}</a>
			<small>{{ his.date }}</small>
		  </h5>
		<p>
		{% if his.attachment %}
		Add attach file <a href="{% load media %}{% media_prefix %}attach/{{ his.attachmentname }}">{{ his.attachment }}</a>
		{% endif %}
		</p>
		<p>{{ his.action|safe|linebreaksbr }}</p>
		{% if his.comment %}
        <p style="background: #F0F0F0; padding: 4px;">{{ his.comment|linebreaksbr }}</p>
		{% endif %}
		</li>
	{% endfor %}
	</ul>
	<p>{{ form.comment.label_tag }}{% if form.comment.field.required %}<font color="red">*</font>{% endif %}</p>	
    {% if form.comment.errors %}<p class="formerrors">{{ form.comment.errors }}</p>{% endif %}	 
	<p>{{ form.comment }}</p>
  </div>

  <div id="fields">
	<div id="field" class="subblock">
		<h3>Fields</h3>
		
		<p><label>Kind</label><samp class="Bug">{{ taskitem.kind }}</samp></p>
		
		<p><label for="severity">Severity</label>{{ form.severity }}</p>
		
		<p><label>Reporter</label><samp>{{ taskitem.reporter }}</samp></p>
		
		<p>
		  <label for="owner">Owner</label>
			{{ form.owner }}
		</p>
	</div>		


	<div id="state" class="subblock">
	  <h3>State</h3>
	  <p id="current_state">{{ taskitem.status }} {% ifequal taskitem.status "Resolved" %}({{ taskitem.resolution }}){% endifequal %}</p>
	  <ul>
		<li>
		{% ifequal taskitem.status "In Progress" %}
		  <input name="new_status" id="idResolved" value="Resolved" type="radio">
		  <label for="idResolved">Resolve</label>
		  {{ form.resolution }}
		</li>
		<li>
		  <input name="new_status" id="idOpen" value="Open" type="radio">
		  <label for="idOpen">Defer work</label>
		{% endifequal %}	
		
		{% ifequal taskitem.status "Resolved" %}
		  <input name="new_status" id="idOpen" value="Open" type="radio">
		  <label for="idOpen">Reopen</label>
		{% endifequal %}


		{% ifequal taskitem.status "Open" %}
		  <input name="new_status" id="idInProgress" value="In Progress" type="radio">
		  <label for="idInProgress">Begin work</label>		
		</li>
		<li>
		  <input name="new_status" id="idResolved" value="Resolved" type="radio">
		  <label for="idResolved">Resolve</label>
		  {{ form.resolution }}
		{% endifequal %}

		{% ifequal taskitem.status "New" %}
		
		  <input name="new_status" id="idInProgress" value="In Progress" type="radio">
		  <label for="idInProgress">Begin work</label>		
		</li>
		<li>
		  <input name="new_status" id="idResolved" value="Resolved" type="radio">
		  <label for="idResolved">Resolve</label>
		  {{ form.resolution }}		
		{% endifequal %}
		
			
        </li>
      </ul>
    </div>
	
	<div id="tag" class="subblock">
		<h3>Tags</h3>
		{{ form.tags }}
	</div>	

	<div id="attachment" class="subblock">
		<h3>Attachment</h3>
		{{ form.attachment.errors }}
			<p>{{ form.attachment }}</p>
	</div>

	<div id="subscribers" class="subblock">
		<h3>Subscribers</h3>
		{{ form.subscribers.errors }}
			{{ form.subscribers }}
	</div>

  </div>	
  <div id="contentfooter"><input type="submit" value="Сохранить" class="comment_submit"></div>	
</form>
  
  
{% endblock %}
